﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using MsDAL;
using Model;
using Components;

namespace UIDesign
{
    public partial class FrmPageList : Form
    {
        Sys5a00DAL sys5a00Dal = new Sys5a00DAL();
        private Sys5a00 selectValue = null;

        public FrmPageList() { }

        public FrmPageList(string flag)
        {
            InitializeComponent();
            Init();
        }

        private void Init()
        {
            DataTable dt = sys5a00Dal.GetPageList(); //得到页面列表

            this.dgvMain.AutoGenerateColumns = false;
            this.dgvMain.DataSource = dt;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.dgvMain.SelectedRows.Count == 0)
            {
                MessageBox.Show("必须选中行!");
                return;
            }

            DataGridViewRow row = this.dgvMain.SelectedRows[0];

            selectValue = new Sys5a00();
            selectValue.Pagename = row.Cells["pagename"].Value.ToString();
            selectValue.Listid = row.Cells["listid"].Value.ToString();
            selectValue.Ctlname = row.Cells["ctlname"].Value.ToString();
            selectValue.Remark = row.Cells["remark"].Value.ToString();
            selectValue.Pagetitle = row.Cells["pagetitle"].Value.ToString();
            selectValue.Colsize = Validation.ToInt(row.Cells["colsize"].Value);
        }

        public Sys5a00 GetSelectedValue()
        {
            return selectValue;
        }

        private void dgvMain_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            button1_Click(null, null);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }
}
